<?php
session_start();
 if (empty($_SESSION['username']) AND empty($_SESSION['passuser'])){
  echo "<link href='style.css' rel='stylesheet' type='text/css'>
 <center>Untuk mengakses modul, Anda harus login <br>";
  echo "<a href=../../index.php><b>LOGIN</b></a></center>";
}
else{
$aksi="modul/mod_banner/aksi_banner.php";
switch($_GET[act]){
  // Tampil Banner
  default:
   ?>
<div id="toolbar-box">
	<div class="t">
		<div class="t">
			<div class="t"></div>
		</div>
	</div>
	<div class="m">
		<div class="toolbar" id="toolbar">
			<table class="toolbar">
            	<tr>
					<td class="button" id="toolbar-new">
  					<a href='?module=banner&act=tambahbanner' onclick="javascript:hideMainMenu(); submitbutton('add')" class="toolbar">
  					<span class="icon-32-new" title="New">
  					</span>Tambah Banner
  					</a>
					</td>
				</tr>
             </table>
		</div>
		<div class="header icon-48-addedit">Data Banner</div>
			<div class="clr"></div>
			</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
</div>
  
 <? 
    echo "<table>
          <tr><th>no</th><th>judul</th><th>url</th><th>tgl. posting</th><th>aksi</th></tr>";
    $tampil=mysql_query("SELECT * FROM banner ORDER BY id_banner DESC");
    $no=1;
    while ($r=mysql_fetch_array($tampil)){
      $tgl=tgl_indo($r[tgl_posting]);
      echo "<tr align=center><td width=30Spx>$no</td>
                <td>$r[judul]</td>
                <td><a href=$r[url] target=_blank>$r[url]</a></td>
                <td>$tgl</td>
                <td width=120px><a href=?module=banner&act=editbanner&id=$r[id_banner] class=tombol>Edit</a> | 
	                  <a href='$aksi?module=banner&act=hapus&id=$r[id_banner]&namafile=$r[gambar]' class=tombol onClick='return hapus()'>Hapus</a>
		        </tr>";
    $no++;
    }
    echo "</table>";
    break;
  
  case "tambahbanner":
   ?>
<div id="toolbar-box">
	<div class="t">
		<div class="t">
			<div class="t"></div>
		</div>
	</div>
	<div class="m">
		<div class="toolbar" id="toolbar">
			<table class="toolbar">
            	<tr>
					<td class="button" id="toolbar-new">
  					<a href=?module=banner onclick="javascript: submitbutton('cancel')" class="toolbar"> <span class="icon-32-cancel" title="Cancel"></span>
Cancel</a></td>
  					<span class="icon-32-new" title="New">
  					</span>
  					</a>
					</td>
				</tr>
             </table>
		</div>
		<div class="header icon-48-addedit">Tambah Banner</div>
			<div class="clr"></div>
			</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
</div>

<script type="text/javascript" src="js/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="js/jquery.validate.pack.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#Form").validate({
		messages: {
			email: {
				required: "E-mail harus diisi",
				email: "Masukkan E-mail yang valid"
			}
		},
		errorPlacement: function(error, element) {
			error.appendTo(element.parent("td"));
		}
	});
})
</script>
<style type="text/css">
input.error, select.error { 
	border: 2px solid red;
	-moz-box-shadow:0 0 10px rgba(255, 0, 0, 0.6);
	-webkit-box-shadow:0 0 10px rgba(255, 0, 0, 0.6);
	}
label.error { color:red; margin-left: 10px; }
</style>
 <?
    echo "<form method=POST action='$aksi?module=banner&act=input' enctype='multipart/form-data' id='Form'>
          <table>
          <tr><td width=150px>Judul</td><td>  : <input type=text name='judul' size=30 class='required' title='&curren; Judul banner Harus diisi'></td></tr>
          <tr><td>Url</td><td>   : <input type=text name='url' size=50 value='http://'></td></tr>
          <tr><td>Gambar</td><td> : <input type=file name='fupload' size=40> *File gambar .jpg</td></tr>
          <tr><td colspan=2><input type=submit value=Simpan class=tombol1>
                            <input type='reset' name'reset' value='Reset' class=tombol1></td></tr>
          </table></form><br><br><br>";
     break;
    
  case "editbanner":
  ?>
<div id="toolbar-box">
	<div class="t">
		<div class="t">
			<div class="t"></div>
		</div>
	</div>
	<div class="m">
		<div class="toolbar" id="toolbar">
			<table class="toolbar">
            	<tr>
					<td class="button" id="toolbar-new">
  					<a href=?module=banner onclick="javascript: submitbutton('cancel')" class="toolbar"> <span class="icon-32-cancel" title="Cancel"></span>
Cancel</a></td>
  					<span class="icon-32-new" title="New">
  					</span>
  					</a>
					</td>
				</tr>
             </table>
		</div>
		<div class="header icon-48-addedit">Edit Banner</div>
			<div class="clr"></div>
			</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
</div>

<script type="text/javascript" src="js/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="js/jquery.validate.pack.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#Form").validate({
		messages: {
			email: {
				required: "E-mail harus diisi",
				email: "Masukkan E-mail yang valid"
			}
		},
		errorPlacement: function(error, element) {
			error.appendTo(element.parent("td"));
		}
	});
})
</script>
<style type="text/css">
input.error, select.error { 
	border: 2px solid red;
	-moz-box-shadow:0 0 10px rgba(255, 0, 0, 0.6);
	-webkit-box-shadow:0 0 10px rgba(255, 0, 0, 0.6);
	}
label.error { color:red; margin-left: 10px; }
</style>
 <?
    $edit = mysql_query("SELECT * FROM banner WHERE id_banner='$_GET[id]'");
    $r    = mysql_fetch_array($edit);

    echo "<form method=POST enctype='multipart/form-data' action=$aksi?module=banner&act=update id='Form'>
          <input type=hidden name=id value=$r[id_banner]>
          <table>
          <tr><td>Judul</td><td>     : <input type=text name='judul' size=30 value='$r[judul]' class='required' title='&curren; Judul banner Harus diisi'></td></tr>
          <tr><td>Url</td><td>      : <input type=text name='url' size=50 value='$r[url]'></td></tr>
          <tr><td>Gambar</td><td>    : <img src='../foto_banner/$r[gambar]'></td></tr>
          <tr><td>Ganti Gbr</td><td> : <input type=file name='fupload' size=30> *) **)</td></tr>
          <tr><td colspan=2>
		  *) Apabila gambar tidak diubah, dikosongkan saja.
		  <br>**) File gambar .jpg
		  </td></tr>
          <tr><td colspan=2><input type=submit value=Update class=tombol1>
                             <input type='reset' name'reset' value='Reset' class=tombol1></td></tr>
          </table></form>";
    break;  
}
}
?>
